package com.dingreading.cloud.soms.service;

import com.alibaba.fastjson.JSONObject;
import com.dingreading.cloud.common.base.R;
import com.dingreading.cloud.common.util.PageDto;
import com.dingreading.cloud.common.util.PageUtil;
import com.dingreading.cloud.soms.dto.*;
import com.dingreading.cloud.soms.entity.Members;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;

import java.util.Date;
import java.util.List;

/**
 * 服务层。
 *
 * @author Administrator
 * @since 2023-11-22
 */
public interface MembersService extends IService<Members> {

    Members getByUid(String storeUid, String uid);

    List<Members> getByUids(List<String> uid);

    List<Members> getByFullName(String fullName);

    List<Members> getByMemberNameAndFullNameAndMob(String storeUid, String keyword);

    List<Members> getByStoreUidAndKeyword(String corpUid, String storeUid, String keyword, Integer enabled);

    Members getMemberInfo(String corpUid, String uid);

    boolean updateEnabled(String storeUid, String uid, Integer enabled, String staffUid, String staffName, Date followTime);

    boolean allotFollowStaff(String storeUid, List<String> memberUid, String staffUid, String staffName);

    boolean giveUp(String storeUid, String memberUid, String staffUid);

    // 查询可加入的班级会员
    PageDto<AddMemberDto> getByServiceMembers(
            PageUtil pageUtil, String corpUid, String storeUid, String fullName, Integer grade, String readStaffUid
    );

    // 查询可加入的试听会员
    PageDto<AddMemberDto> getAuditionMembers(
            PageUtil pageUtil, String corpUid, String storeUid, String keyword
    );

    // 查询可加入的班级会员或试听会员
    PageDto<AddMemberDto> serviceMemberList(
            PageUtil pageUtil, String corpUid, String storeUid, String fullName, Integer grade,
            String projectUid, String readStaffUid
    );

    List<JSONObject> getCorpMembers(String corpUid, String storeUid, String keyword);

    // 更新最后跟进时间
    void updateLastFollowInfo(String storeUid, String memberUid, String followUid, Date followTime);

    // 批量更新最后跟进时间
    void updateFollowTimes(String storeUid, List<String> memberUids, Date time);

    // 判断公司下有无同手机号和姓名的会员
    Members haveCorpUidAndMobAndFullName(String corpUid, String mob, String fullName, String uid);

    // 判断公司下有无同微信号和姓名的会员
    Members haveCorpUidAndWxNameAndFullName(String corpUid, String wxName, String fullName, String uid);

    // 判断门店下有无同手机号和姓名的会员
    Members haveCorpUidAndStoreUidAndMobAndFullName(String corpUid, String storeUid, String mob, String fullName);

    PageDto<MembersDto> getMemberListByType(
            PageUtil pageUtil, boolean managerOrAdvisor, String storeUid, String keyword, Integer enabled,
            String beginDate, String endDate, String followStaffUid, Integer grade, Integer memberType,
            String customSource, String channelUid
    );

    boolean haveChannelUid(String storeUid, String channelUid);

    boolean updateValidStatus(String storeUid, String uid, int validStatus, String staffUid, String staffName);

    // 删除会员线索
    int dropClueMember(String storeUid, String uid);

    // 更新会员的门店信息
    boolean updateStoreInfo(String storeUid, String memberUid, Long storeId, String toStoreUid, String toStoreName);

    // 获取会员的年级、姓名、会员uid（阅读兴趣测评）
    Members getByUid(String uid);

    // 获取可借阅会员
    List<MemberBorrowDto> borrowMemberList(String corpUid, String storeUid, String keyword);

    // 获取可借阅会员
    List<MemberBorrowDto> borrowMemberList(List<String> storeUidList, String keyword);

    // 获取相同名字的最大序号
    MaxFullNameDto maxFullName(String fullName);

    List<Members> listByPhoneList(List<String> searchPhoneList);

    // 线索分页
    Page<MemberClueDto> getMemberClueList(
            PageUtil pageUtil, String storeUid, String keyword, Integer enabled, String beginDate, String endDate,
            String followStaffUid, Integer grade, String customSource, String channelUid, String refererStaffUid,
            String addStaffUid, Integer validStatus
    );

    List<MemberUidSourceDto> listByAddTimeBetween(String storeUid, String beginDate, String endDate);

    /*名师堂*/
    List<Members> findByMobAndFullName(String storeUid, String mob, String fullName);

    void updateDatabaseType(String uid, String mstUid, int databaseType);

    List<Members> mstMemberList(String storeUid);

    List<Members> getByPhone(String phone);

    List<Members> listByStoreUidAndMstUid(String storeUid, List<String> studentUidList);

    R<Object> setReferer(
            String corpUid, String storeUid, String storeName,
            String staffUid, String staffName, List<String> uids, String refererStaffUid
    );
}
